----------- 做出自定义死亡通告


local function Upgrade_func()
    local _G = GLOBAL
    if _G.GetNewDeathAnnouncementString then
        local GetNewDeathAnnouncementString___npc_old = _G.GetNewDeathAnnouncementString
        _G.GetNewDeathAnnouncementString = function(theDead,source,...)
            --  source is string 
            -- print("info GetNewDeathAnnouncementString" ,theDead)
            if theDead and theDead.npc_everything_data and theDead.npc_everything_data:Get("death_announce") then
                local str_table = theDead.npc_everything_data:Get("death_announce")
                if type(str_table)  == "string" then
                    theDead.npc_everything_data:Set("death_announce",nil)
                    return str_table
                elseif type(str_table) == "table" then
                    if str_table.source == source then
                        local str = str_table.announce or ""
                        theDead.npc_everything_data:Set("death_announce",nil)                
                        return str
                    end
                end
            end
            return GetNewDeathAnnouncementString___npc_old(theDead,source,...)
        end
        -- print("info GetNewDeathAnnouncementString upgraded")
    end

end


AddPrefabPostInit(
    "world",
    function(inst)
        inst:DoTaskInTime(0,function()
            Upgrade_func()            
        end)
end)

-- if _G.GetNewRezAnnouncementString then
--     _G.GetNewRezAnnouncementString___npc_old = _G.GetNewRezAnnouncementString
--     _G.GetNewRezAnnouncementString = function(theRezzed, source,...)
--         print(theRezzed,source)
--         if theRezzed and theRezzed.npc_everything_data and theRezzed.npc_everything_data:Get("rez_announce") then
--             local str_table = theRezzed.npc_everything_data:Get("rez_announce")
--             if type(str_table)  == "string" then
--                 theRezzed.npc_everything_data:Set("rez_announce",nil)
--                 return str_table
--             elseif type(str_table) == "table" then
--                 if str_table.source == source then
--                     local str = str_table.announce or ""
--                     theRezzed.npc_everything_data:Set("rez_announce",nil)                
--                     return str
--                 end
--             end
--         end
--         return _G.GetNewRezAnnouncementString___npc_old(theRezzed,source,...)
--     end

-- end